# encoding: utf-8

# 初始数据库表结构
class InitTables < ActiveRecord::Migration
  
  def change
    create_table :categories, comment: "新闻栏目" do |t|
      t.string  :enmae,     comment: '英文栏目名称'
      t.string  :cataname,  comment: '中文栏目名称'
      t.integer :father,    comment: '父栏目ID', :default => 0, :null => false
      t.integer :order,     comment: '顺序',     :default => 0, :null => false

      t.timestamps
    end

    create_table :sptitles, comment: "专题" do |t|
      t.string  :name,    comment: '专题名字'
      t.integer :over,    comment: '是否已经结束', :default => 0, :null => false
      t.integer :orders,  comment: '顺序',        :default => 0, :null => false
      t.string  :file_id, comment: '附件ID'

      t.timestamps
    end

    create_table :departments, comment: "部门" do |t|
      t.string  :name,       comment: '部门名称'
      t.string  :short_name, comment: '部门简称'
      t.integer :orders,     comment: '顺序', :default => 0, :null => false
      
      t.timestamps
    end

    create_table :reports, comment: "学术报告" do |t|
      t.string   :title,      comment: '报告标题'
      t.string   :place,      comment: '地点'
      t.string   :reporter,   comment: '报告人姓名'
      t.datetime :time,       comment: "报告时间"
      t.integer  :screen,     comment: '首屏顺序'
      t.integer   :check,     comment: '审查状态'
      t.string   :content,    comment: '正文'
      t.string   :note,       comment: '备注'
      t.string   :writer,     comment: '录稿人姓名'
      t.string   :postby,     comment: '发布人姓名'
      t.string   :fromwhere,  comment: '部门具体负责人姓名'
      t.string   :department, comment: '部门名称'
      t.integer  :orders,     comment: '顺序', :default => 0, :null => false
      
      t.timestamps
    end

    create_table :news, comment: "新闻"  do |t|
      t.integer  :category_id,               comment: '新闻类型'
      t.integer  :is_important_news,         comment: '是否要闻(0:不是,1:是)'
      t.string   :title,                     comment: '标题'
      t.string   :bottomtitle,               comment: '副标题'
      t.string   :uptitle,                   comment: '肩标题'
      t.string   :author_name,               comment: '作者名'
      t.string   :cameraman_name,            comment: '摄影师'
      t.string   :phone,                     comment: '联系电话'
      t.string   :contribution_units,        comment: '发布单位名称'
      t.integer  :contribution_units_id,     comment: '发布单位ID'
      t.string   :contribution_units_member, comment: '发布单位具体负责人'
      t.string   :writer,                    comment: '录稿人姓名'
      t.string   :postby,                    comment: '发布人姓名'
      t.text     :body,                      comment: '正文'
      t.string   :keywords,                  comment: '关键词'    
      t.string   :toback_reason,             comment: '退回原因（最近1次）'
      t.integer  :toback_count,              comment: '退回次数'
      t.integer  :check,                     comment: '是否已审查', :default => 0, :null => false
      t.integer  :edit,                      comment: '是否可编辑', :default => 0, :null => false
      t.integer  :hits,                      comment: '点击次数'

      t.string   :pubwhere,                  comment: '发布地址'
      t.string   :puburl,                    comment: '发布URL'
      t.string   :pubversion,                comment: '发布版本'
      t.datetime :pubtime,                   comment: '发布时间'  

      t.datetime :edittime,                  comment: '编辑时间'
      t.string   :editby,                    comment: '编辑人姓名'
      t.integer  :english,                   comment: '是否英文稿件', :default => 0, :null => false

      t.integer  :home_page_location,        comment: '首页显示位置（0: 不显示在首页, 1: 显示在校园要闻， 2: 显示在校园快讯, 3: 显示在深度报道， 4: 显示媒体华理, 5: 显示在图说华丽）', :default => 0, :null => false
      t.string   :home_page_image,           comment: '首页显示图片'
      t.integer  :sort_score,                comment: '置顶分数', :default => 0, :null => false
 
      t.timestamps
    end

    create_table :news_sptitles,   comment: "新闻专题中间表" do |t|
      t.integer :news_id,          comment: '新闻外键'
      t.integer :sptitle_id,       comment: '专题外键'

      t.timestamps
    end

    #create_table :platforms, comment: "平台" do |t|
    #  t.string  :name,       comment: '平台名称'
    #  t.timestamps
    #end

    #create_table :news_platforms, comment: "新闻和平台中间表" do |t|
    #  t.integer  :news_id,      comment: '新闻外键'
    #  t.integer  :platform_id,  comment: '平台外键'
    #  t.timestamps
    #end

    create_table :news_groups, comment: "新闻和平台中间表" do |t|
      t.integer  :news_id,      comment: '新闻外键'
      t.integer  :group_id,  comment: '平台外键'
      t.timestamps
    end

    create_table :toback, comment: "退回详情" do |t|
      t.string :reason, comment: '原因'
      t.string :kind,   comment: '退回类型'

      t.timestamps
    end

    create_table :top_news, comment: "大图新闻栏" do |t|
      t.string  :title,       comment: '标题'    
      t.string  :content,     comment: '内容'
      t.string  :link_url,    comment: '新闻链接地址'
      t.string  :first_image, comment: '第1张图片'  
      t.string  :second_image,comment: '第2张图片'  
      t.string  :third_image, comment: '第3张图片'
      t.string  :fourth_image,comment: '第4张图片'
      t.string  :fifth_image, comment: '第5张图片'
      t.integer :status,  comment: '是否生效: 0=不生效，1=生效', :default => 0, :null => false

      t.timestamps
    end
    
    create_table :new_media, comment: "新媒体入口" do |t|
      t.string  :name,             comment: '媒体名字'
      t.string  :link_url,         comment: '新媒体入口地址'
      t.string  :mouse_off_image,  comment: '默认图片地址'
      t.string  :mouse_on_image,   comment: '高亮图片地址'
      t.integer :postion_num,      comment: '位置'
      t.timestamps
    end

    create_table :notifies, comment: "通知公告" do |t|
      t.string   :title,    comment: '标题'
      t.text     :content,  comment: '内容'
      t.integer  :status,   comment: '状态'
      t.datetime :deleted,  comment: '删除时间'

      t.timestamps
    end

    create_table :weixins, comment: '微信稿件' do |t|
      t.string :author,               comment: '作者姓名'
      t.string :contribute_unit_name, comment: '来稿单位'
      t.string :phone,                comment: '电话'
      t.text   :content,              comment: '正文'

      t.timestamps
    end

    create_table :weibos, comment: '微博稿件' do |t|
      t.string :author,               comment: '作者姓名'
      t.string :contribute_unit_name, comment: '来稿单位'
      t.string :phone,                comment: '电话'
      t.text :content,                comment: '普通微博'
      t.text :long_content,           comment: '长微博'

      t.timestamps
    end

  end
end
